package cn.itcast.bos.consumer;

import cn.itcast.bos.utils.LocalHostMailUtils;
import cn.itcast.bos.utils.MailUtils;
import org.springframework.stereotype.Service;

import javax.jms.JMSException;
import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.MessageListener;

@Service
//发送邮件的类
public class SendMailConsumer implements MessageListener {
    @Override
    public void onMessage(Message message) {
        MapMessage mapMessage = (MapMessage) message;

        //调用接口,发送邮件
        /*try {
            MailUtils.sendMail("速运快递激活邮件",mapMessage.getString("content"),mapMessage.getString("email"));

        } catch (JMSException e) {
            e.printStackTrace();
        }*/
        try {
            LocalHostMailUtils.sendMail(mapMessage.getString("email"),mapMessage.getString("activeCode"),mapMessage.getString("telephone"));
        } catch (JMSException e) {
            e.printStackTrace();
        }


    }
}
